import java.util.*;
public class Solution {
    public static void merge(int A[], int m, int B[], int n) {
        int i = m-1;
        int j = n-1;
        int x = m+n-1;
        while(j >= 0) {
            if(i==0 || B[j] > A[i]) {
                A[x] = B[j];
                x--;
                j--;
            } else {
                A[x] = A[i];
                x--;
                i--;
            }
        }
    }

    public static void main(String[] args) {
        int[] A = new int[]{1,2,3,0,0,0};
        int[] B = new int[]{1,2,3};
        merge(A,3,B,3);
        System.out.println(A.toString());

    }
}